
import axiosInstance from './httpRequest';
import { postData } from './httpRequest'
import { getCookie } from '../utils/common';

export const handleLogin = (data) => {
    return axiosInstance.post('/survey/login', data);
}


export const getList = (data) => {
    let token = getCookie("survey_user_token")
    return axiosInstance.post('/survey/front/surveyList?token=' + (token?JSON.parse(token):''), {});
}

export const handleLogout = (data) => {
    return axiosInstance.post('/survey/logout', data);
}


export const getMySurveys = (data) => {
    let token = getCookie("survey_user_token")
    return axiosInstance.get('/survey/front/mySurveys?token=' + (token?JSON.parse(token):''), data);
}

export const surveyDetail = () => {  
    let token = getCookie("survey_user_token")
    return axiosInstance.post('/survey/front/surveyDetail?token=' + (token?JSON.parse(token):''), {id: 2}) 
}

// 添加问卷
export const addSuevey = (data) => {
    let token = getCookie("survey_user_token")
    return axiosInstance.post('/survey/admin/addSurvey?token=' + (token?JSON.parse(token):''), data) 
}

export const publishSurvey = (data) => {
    let token = getCookie("survey_user_token")
    return axiosInstance.post('/survey/admin/publishSurvey?token=' + (token?JSON.parse(token):''), data) 
}



// 添加问题
export const addQuestions = (data) => {
    let token = getCookie("survey_user_token")
    return axiosInstance.post('/survey/admin/addQuestions?token=' + (token?JSON.parse(token):''), data) 
}


//审核列表

export const waitingAuditSurveys = (data) => {
    let token = getCookie("survey_user_token")
    return axiosInstance.post('/survey/admin/waitingAuditSurveys?token=' + (token?JSON.parse(token):''), data) 
}

// 审核的问卷详情
export const auditSurveyDetail = (data) => {
    let token = getCookie("survey_user_token")
    return axiosInstance.post('/survey/admin/auditSurveyDetail?token=' + (token?JSON.parse(token):''), data) 
}

// 审核问卷
export const auditSurvey = (data) => {
    let token = getCookie("survey_user_token")
    return axiosInstance.post('/survey/admin/auditSurvey?token=' + (token?JSON.parse(token):''), data) 
}

// 分析问卷
export const surveyStatics = (data) => {
    let token = getCookie("survey_user_token")
    return axiosInstance.post('/survey/admin/surveyStatics?token=' + (token?JSON.parse(token):''), data) 
}

// 我的积分
export const myPoints = (data) => {
    let token = getCookie("survey_user_token")
    return axiosInstance.post('/survey/front/myPoints?token=' + (token?JSON.parse(token):''), data) 
}

// 我的明细
export const myPointsDetail = (data) => {
    let token = getCookie("survey_user_token")
    return axiosInstance.post('/survey/front/myPointsDetail?token=' + (token?JSON.parse(token):''), data);
}

// 开始问卷
export const startSurvey = (data) => {
    console.log(data)
    let token = getCookie("survey_user_token")
    return axiosInstance.post('/survey/front/startSurvey?token=' + (token?JSON.parse(token):''), data);
}

// 开始问卷
export const finishSurvey = (data) => {
    console.log(data)
    let token = getCookie("survey_user_token")
    return axiosInstance.post('/survey/front/finishSurvey?token=' + (token?JSON.parse(token):''), data);
}


// 暂存问卷
export const saveProgress = (data) => {
    let token = getCookie("survey_user_token")
    return axiosInstance.post('/survey/front/saveProgress?token=' + (token?JSON.parse(token):''), data);
}
